package GUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class scoreWindow extends JFrame {

    public static void main(String[] args) {
        scoreWindow demo=new scoreWindow();
        demo.setVisible(true);
    }

    public int totalScore;
    public JLabel lab4,lab5;
    public JPanel mainPanel;
    public scoreWindow(){}

    public scoreWindow(int sel,int def){
        totalScore=sel+def;
        mainPanel = new JPanel();
        JLabel lab1=new JLabel("您本次客观题得分为："+totalScore);
        JLabel lab2=new JLabel("选择题得分为："+sel+"分");
        JLabel lab3=new JLabel("判断题得分为："+def+"分");
        lab5=new JLabel("");
        lab4=new JLabel("主观题得分请等待老师批改后查看");
        JButton but = new JButton("返回");
        this.setSize(300,300);
        mainPanel.setSize(this.getSize());
        mainPanel.setLayout(null);
        lab1.setBounds(50,30,300,20);
        lab2.setBounds(50,60,300,20);
        lab3.setBounds(50,90,300,20);
        lab4.setBounds(50,120,300,20);
        lab5.setBounds(50,150,300,20);
        but.setBounds(120,190,80,30);
        mainPanel.add(lab1);
        mainPanel.add(lab2);
        mainPanel.add(lab3);
        mainPanel.add(lab4);
        mainPanel.add(lab5);
        mainPanel.add(but);
        but.setBackground(Color.lightGray);
        but.addActionListener(new backListener());
        this.setContentPane(mainPanel);
        this.setLocationRelativeTo(null);//居中
        this.setVisible(false);
        this.setTitle("在线考试平台");

        //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public scoreWindow(int selectionRightNum,int definitionRightNum,int selectionNum,int definitionNum,int selectionScore,int definitionScore){
            totalScore=selectionScore+definitionScore;
            mainPanel = new JPanel();
            JLabel lab1=new JLabel("您本次客观题得分为："+totalScore);
            JLabel lab2=new JLabel("选择题： "+selectionRightNum+"/"+selectionNum+"  得分为："+selectionScore+"分");
            JLabel lab3=new JLabel("判断题： "+definitionRightNum+"/"+definitionNum+"  得分为："+definitionScore+"分");
            lab5=new JLabel("");
            lab4=new JLabel("主观题得分请等待老师批改后查看");
            JButton but = new JButton("返回");
            this.setSize(300,300);
            mainPanel.setSize(this.getSize());
            mainPanel.setLayout(null);
            lab1.setBounds(50,30,300,20);
            lab2.setBounds(50,60,300,20);
            lab3.setBounds(50,90,300,20);
            lab4.setBounds(50,120,300,20);
            lab5.setBounds(50,150,300,20);
            but.setBounds(120,190,80,30);
            mainPanel.add(lab1);
            mainPanel.add(lab2);
            mainPanel.add(lab3);
            mainPanel.add(lab4);
            mainPanel.add(lab5);
            mainPanel.add(but);
            but.setBackground(Color.lightGray);
            but.addActionListener(new backListener());
            this.setContentPane(mainPanel);
            this.setLocationRelativeTo(null);//居中
            this.setVisible(false);
            this.setTitle("在线考试平台");

            //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
        public class backListener implements ActionListener {

            @Override
            public void actionPerformed(ActionEvent e) {//关闭注册界面
                scoreWindow.this.dispose();

            }
        }
    }


